def max_subarray_sum(nums):
    max_sum = current_sum = nums[0]
    
    for num in nums[1:]:
        current_sum = max(num, current_sum + num)
        max_sum = max(max_sum, current_sum)
        
    return max_sum

# 输入
array = list(map(int, input("请输入整数数组，用空格分隔: ").split()))
# 输出
print("子数组之和的最大值:", max_subarray_sum(array))
